<?
	 layout("/inc/win_layout.html",{title:sysTitle}){
    ?>

<div class="">
	<div class="col-lg-12">
		<div class="panel panel">
			<div class="panel-body pan" style="min-height: 220px;">
				<div class="form-body pal" >
					<ul id="tree" class="ztree" style=""; overflow:auto;"></ul>
	                <div id="dataNull" class="panel-body" style=" line-height: 50px;" align="center"></div>
				</div>
			</div>
		</div>
	</div>
</div>
<?}?>
<script type="text/javascript">
$(function() {
	initTree() 
});
function initTree() {
	$.ajax({
		type : "post",
		url : "./KnowledgeclassListall.do",
		dataType : "json",
		beforeSend : function(XMLHttpRequest) {
		},
		success : drawTree,
	});
}

function drawTree(data) {
	var setting = {
		check: {
			enable: true,
			nocheckInherit: true,
			chkboxType: {"Y" : " ", "N" : " "}
		},
		view: {
			dblClickExpand: false
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		callback : {
			onClick : onClick
		},
	};
	var zNodes = eval(data);
		if(data.length>0){
				$("#dataNull").hide();
			}else{
				$("#dataNull").html("<span class='subtitle' style=\"font-size: 15px;\">数据为空!</span>");
			}	
	$.fn.zTree.init($("#tree"), setting, zNodes).expandAll(true);
	zTree = $.fn.zTree.getZTreeObj("tree");
	zTree.checkAllNodes(true);
	zTree.expandNode(zTree.getNodes()[0], true);//指定某节点折叠
}
function onClick(e, treeId, treeNode) {
	classid = treeNode.id;
	classname = treeNode.name;
}
	
function start(){
	var treeObj = $.fn.zTree.getZTreeObj("tree");
	var checkedNode = treeObj.getCheckedNodes(); 
	var menuids="";
	for(var i=0;i<checkedNode.length;i++){
		if(checkedNode[i].id!=null){
			menuids+=checkedNode[i].id+",";
		}
	}
	if (menuids != ''){
		var index = parent.layer.getFrameIndex(window.name);
		parent.$("#classesIds").val(menuids);
   		parent.layer.close(index);
	}else{
		alert("请选择知识库");
	}
}
</script>